﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Threading;
using System.Globalization;
using Nivdal.AuxCode;

namespace Nivdal
{
    public partial class ForumConversations : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = Resources.Resource.Default_PageTitle + ", " + Resources.Resource.ForumConversations_PageTitle;
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
                Response.Redirect("~/Default.aspx");
            OnlineUser ou = (OnlineUser)Session["User"];
            if (ou.TeamId == "Null")
                Response.Redirect("~/GeneralMessage.aspx?MessageString=M74ggdizz5wfeh");

            if (!IsPostBack)
            {
                this.ForumGetMyConversationSqlDataSource.SelectParameters.Add("UserId", ou.UserId);
            }

            if (Request.QueryString["Message"] != null)
            {
                this.MessageLabel.Text = Request.QueryString["Message"];
            }
            else
            {
                this.MessagePanel.Visible = false;
            }

        }
        protected override void InitializeCulture()
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
        }

        protected void MarkAllAsRead(object sender, EventArgs e)
        {
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            OnlineUser ou = (OnlineUser)Session["User"];
            string Answer = GND.ReadNivdalStringData("UserId", "Nivdal_ForumMarkAllConversationsAsRead", ou.UserId);
            Response.Redirect("ForumConversations.aspx?Message=" + Answer);
        }
    }
}